package com.natasha.pins.bh.pinsmaster;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;

import com.natasha.pins.data.bean.PinsMasterBean;

public class Datasource
{
    //Singleton pattern
    private static Datasource datasource = null;
    
    private List<PinsMasterBean> data=null;
	private PinsMasterBH pinsMasterBH;
     
    //private List data = null;
     
    private static final int SIZE = 74;
    
    private Context context;
     
    public static Datasource getInstance(Context context )
    {
        if (datasource == null)
        {
            datasource = new Datasource(context);
        }
        return datasource;
    }
     
    private Datasource(Context context)
    {
    	this.context = context;
    	
    	pinsMasterBH = new PinsMasterBH(context);
		pinsMasterBH.fetchAllPins();
		
        data = pinsMasterBH.getPinsMasterBeanList();       
    }
     
    public int getSize()
    {
        return SIZE;
    }
     
    public List getData(int offset, int limit)
    {
        List newList = new ArrayList(limit);
        int end = offset + limit;
        if (end > data.size())
        {
            end = data.size();
        }
        newList.addAll(data.subList(offset, end));
        return newList;     
    }
 
}